import {
  Constant_Enum_Enum_Scheduled_Type,
  Constant_Enum_Enum_Scheduled_Status,
  IConstant_Enum_Type_Scheduled_Status,
  IConstant_Enum_Type_Scheduled_Enum_Type,
} from '@/common/constants/enum';
import { ApiProperty } from '@nestjs/swagger';
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class Scheduled {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  @ApiProperty({ description: '调度名称' })
  scheduledName: string;

  @Column()
  @ApiProperty({ description: '类型', enum: Constant_Enum_Enum_Scheduled_Type })
  scheduleddType: IConstant_Enum_Type_Scheduled_Enum_Type;

  @Column({ default: Constant_Enum_Enum_Scheduled_Status.SCHEDULED_STATUS_PENDING })
  @ApiProperty({
    default: Constant_Enum_Enum_Scheduled_Status.SCHEDULED_STATUS_PENDING,
    description: '状态',
    enum: Constant_Enum_Enum_Scheduled_Status,
  })
  status: IConstant_Enum_Type_Scheduled_Status;

  @Column({ type: 'bigint', nullable: true })
  @ApiProperty({ type: 'bigint', description: '完成时间' })
  scheduledd_at?: number;

  @Column({ nullable: true })
  @ApiProperty({ description: '详情信息' })
  scheduleddDetail?: string;

  @CreateDateColumn({
    type: 'datetime',
    precision: 0,
    default: () => 'CURRENT_TIMESTAMP(0)',
    onUpdate: 'CURRENT_TIMESTAMP(0)',
  })
  createTime: Date;
}
